package com.woniu.cloud.shopassembly.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniu.cloud.common.dto.Result;
import com.woniu.cloud.entity.TGood;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * <p>
 * 平台对店铺商品表 服务类
 * </p>
 *
 * @author hyy
 * @since 2021-09-22
 */
public interface ITGoodService extends IService<TGood> {



    @CachePut(cacheNames = "cachegood:id",key="#goodId")
    TGood updateRedis(Integer goodId);

    @Cacheable(cacheNames = "cachegood:id",key="#goodId")
    TGood insertRedis(Integer goodId);



    /**
     * TODO 查询----------------------------------------------
     */


//    @Cacheable(cacheNames = "cachegood:id",key="#goodId")
    TGood getGoodByGoodId(Integer goodId);

//    @Cacheable(cacheNames = "cachegood:name",key="#p0+#p1")
    Result getGoodByGoodName(String goodName,Integer pageIndex);

//    @Cacheable(cacheNames = "cachegood:type",key="#p0+#p1")
    Result getGoodByGoodType(String goodType, Integer pageIndex);

//    @Cacheable(cacheNames = "cachegood:typeList")
    Result getGoodTypeList();

    /**
     * TODO 添加----------------------------------------------
     */
    Result insertGood(TGood good);
    /**
     * TODO 修改----------------------------------------------
     */
    Result updateGoodByGoodId(TGood good);

    Result updateGoodNumByGoodId(Integer goodId, Integer goodNum);

    Result updateGoodSellNumByGoodId(Integer goodId, Integer goodSellNum);
    /**
     * TODO 删除----------------------------------------------
     */
    @CacheEvict(cacheNames = "cachegood:id",key = "#goodId")
    Result deleteGoodByGoodId(Integer goodId);
}
